<?php

namespace App\Admin\Actions\Grid\User;

use App\Admin\Forms\User\ReviewForm;
use Dcat\Admin\Grid\BatchAction;
use Dcat\Admin\Widgets\Modal;

class ReviewBatchAction extends BatchAction
{
    /**
     * @return string
     */
    protected $title = '批量审核';

    public function render()
    {
        $form = ReviewForm::make();
        return Modal::make()
            ->lg()
            ->title($this->title)
            ->body($form)
            ->onLoad($this->getModalScript())
            ->button('<a href="javascript:void(0)"><i class="feather icon-check"> ' . $this->title . '</i></a>');
    }

    protected function getModalScript(): string
    {
        return <<<JS
var key = {$this->getSelectedKeysScript()}
$('#batch-ids').val(key);
/*
$('.field_payment_address_id').change(function (){
    var id = $(this).val();
    $.ajax({
        type: 'GET',
        url: '/admin/payment-address-key',
        data: {'id':id},
        dataType: 'json',
        success: function (data){
            $(".field_key").val(data.data.key)
        }
    });

});
 */
JS;

    }
}
